package flow.service;

import flow.model.FlowBusiness;
import m.common.service.Service;
import m.system.exception.MException;
import manage.model.AdminLogin;

public abstract class FlowService extends Service implements IFlowService {
    /**
     * 保存流程业务信息 业务oid唯一覆盖 并启动流程
     * admin 申请人
     * 业务信息 oid type title
     */
    public void saveAndStartFlow(String adminOid,String deptOid, String oid, String type, String title) throws Exception {
        FlowBusiness business=getService(FlowBusinessService.class).toFlowBusiness(adminOid,deptOid,oid,type,title,this.getClass().getName());
        getService(FlowInstanceService.class).start(this.getFlowIdentity(),business);
    }
    /**
     * 保存流程业务信息 业务oid唯一覆盖 不启动流程
     * admin 申请人
     * 业务信息 oid type title
     */
    public void saveFlowBusiness(String adminOid,String deptOid, String oid, String type, String title) throws Exception {
        getService(FlowBusinessService.class).toFlowBusiness(adminOid,deptOid,oid,type,title,this.getClass().getName());
    }

    /** oid 业务主键
     * 设置下一步默认人
     * selectable
     */
    public void setNextDefaultUser(String oid,String[] admins, boolean selectable) throws MException {
        getService(FlowBusinessService.class).updateNextDefaultUser(oid,admins,selectable);
    }

    /**
     * 设置下一步选人限制  指定部门和指定角色限制
     */
    public void setNextUser4Limit(String oid,String[] toOrg,String[] toRole) throws MException {
        getService(FlowBusinessService.class).updateNextUser4Limit(oid,toOrg,toRole);
    }
    /**
     * 设置下一步选人限制  录入人部门和指定角色限制
     */
    public void setNextUser4Dept(String oid,String... toRole) throws MException {
        getService(FlowBusinessService.class).updateNextUser4Dept(oid,toRole);
    }
    /**
     * 设置下一步选人限制  录入人机构和指定角色限制
     */
    public void setNextUser4Org(String oid,String... toRole) throws MException {
        getService(FlowBusinessService.class).updateNextUser4Org(oid,toRole);
    }
}